// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.designer.ui.process.models;

import org.dengues.core.process.CompElement;
import org.dengues.core.process.ICompProcess;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;

/**
 * Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * @since 2007-10-8 下午09:55:40
 */
public class CompNodeLabel extends CompElement {

    private String nodeLabel;

    private final CompNode parent;

    public static String PROP_TEXT_CHANGE = "CompNodeLabel_textChange"; //$NON-NLS-1$

    public static String PROP_LOCATION_CHANGE = "CompNodeLabel_LOCATIONChange"; //$NON-NLS-1$

    private Point location = new Point(0, 0);

    /**
     * 
     */
    private static final long serialVersionUID = 134242422223329L;

    /**
     * Qiang.Zhang.Adolf@gmail.com CompNodeLabel constructor comment.
     */
    public CompNodeLabel(String nodeLabel, CompNode parent) {
        this.nodeLabel = nodeLabel;
        this.parent = parent;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.dengues.designer.ui.process.models.CompElement#getCompName()
     */
    @Override
    public String getCompName() {
        return nodeLabel;
    }

    /**
     * Getter for nodeLabel.
     * 
     * @return the nodeLabel
     */
    public String getNodeLabel() {
        return this.nodeLabel;
    }

    /**
     * Sets the nodeLabel.
     * 
     * @param nodeLabel the nodeLabel to set
     */
    public void setNodeLabel(String nodeLabel) {
        this.nodeLabel = nodeLabel;
        fireStructureChange(PROP_TEXT_CHANGE, this.nodeLabel);
    }

    /**
     * Getter for location.
     * 
     * @return the location
     */
    @Override
    public Point getLocation() {
        return this.location;
    }

    /**
     * Sets the location.
     * 
     * @param location the location to set
     */
    public void setLocation(Point location) {
        this.location = location;
        fireStructureChange(PROP_LOCATION_CHANGE, this.location);
    }

    /**
     * Getter for size.
     * 
     * @return the size
     */
    @Override
    public Dimension getSize() {
        return null;
    }

    /**
     * Getter for parent.
     * 
     * @return the parent
     */
    public CompNode getParentNode() {
        return this.parent;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.dengues.designer.ui.process.models.CompElement#getCompProcess()
     */
    @Override
    public ICompProcess getCompProcess() {
        if (parent != null) {
            return parent.getCompProcess();
        }
        return null;
    }

}
